﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace weba
{
    public partial class mychat : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
             //            this.TextArea1.InnerText = "欢迎访问宁波中欣数码有限公司，客服1竭诚为您服务" + "<br />";
            if (!IsPostBack)
            {
                kefuchat.ycount += 1;

            }
            else
            {
             this.Label1.Text = "游客" + kefuchat.ycount.ToString();
                string b = "欢迎访问宁波中欣数码有限公司，客服1竭诚为您服务" + "<br />";
                foreach (youke y in kefuchat.lyk.Where(h => h.seionid == Session.SessionID.ToString()))
                {
                    b += y.ykname.ToString() + "于" + y.dtm.ToString() + "说" + "<br />" + y.message + "<br />";

                }
                this.TextArea1.InnerText = b;
                
             }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            
            string a = this.TextArea2.InnerText;
            kefuchat.lyk.Add(new youke() { ykname = this.Label1.Text,dtm=System.DateTime.Now.ToString(),seionid=Session.SessionID.ToString(),message=a });
          
            //  =
            string b = "欢迎访问宁波中欣数码有限公司，客服1竭诚为您服务" + "<br />";
            foreach (youke y in kefuchat.lyk.Where(h => h.seionid == Session.SessionID.ToString()|h.ykname=="客服"))
            {
                b += y.ykname.ToString() + "于" + y.dtm.ToString() + "说" + "<br />" + y.message + "<br />";

            }
            this.TextArea1.InnerText = b;
              this.TextArea2.InnerText = "";
        }

        //protected void Button2_Click(object sender, EventArgs e)
        //{

        //   // Response.Redirect(Request.RawUrl.ToString());
        //    string b = "欢迎访问宁波中欣数码有限公司，客服1竭诚为您服务" + "<br />";
        //    foreach (youke y in kefuchat.lyk.Where(h => h.seionid == Session.SessionID.ToString()|h.ykname=="客服"))
        //    {
        //        b += y.ykname.ToString() + "于" + y.dtm.ToString() + "说" + "<br />" + y.message + "<br />";

        //    }
        //    this.TextArea1.InnerText = b;
        //    this.TextArea2.InnerText = "";
        //}
    }
}